<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JSON数据</title>
</head>
<body>
    <script>
        let obj = {
            name : "xiaxia",
            show : {
                tag : "做自己",
                age : 18
            }
        };

        // 对象转化为json字符串
        let json = JSON.stringify(obj,null,2);
        console.log(json);

        
        // 任何类型都可以转化成json字符串
        let arr = ['xiasnn','后盾人'];
        let arrJson = JSON.stringify(arr,null,2);
        console.log(arrJson);


        let phpJson = `{"name":"\u540e\u76fe","url":"hdr.com"}`;
        // 将json字符串转化为对象
        let oo = JSON.parse(phpJson);
        console.log(oo);
        console.log(oo.url);
    </script>
</body>
</html>